added keyword argument to UARTDevice to set power on one of the power…#468
added keyword argument to UARTDevice to set power on one of the power…#468ste7anste7an wants to merge 1 commit into
Conversation
|
The tricky part about allowing this is that we won't have a way to automatically turn off the power when a custom device is unplugged. We could turn power off at the end of the program for safety reasons, but I imagine you'd want to keep it on between runs just like the Ultrasonic Sensor. A few ideas:
|
|
I have pushed an alternative branch here to implement the second option discussed above. The ready made firmware files can be download here. The I do not currently have the equipment to test this. @ste7anste7an, could you please test the following on all hubs? Please confirm the polarity for I think we can include this in the next release after full testing. |
The UARTDevice iodevice is a nice generic way to communicate with external devices using plain uart communciation. When external devices have more power needs than the 3v3 line can deliver (e.g. when driving NeoPixels or Servo motors), it would be nice when such a device can use 8V power coming from one of the power lines P1 or P2.
The PUPDevice iodevice allows for setting power on either P1 or P2 depending how that is negotiatied in the PUP protocol. For I2CDevices, there is a keyword argument powered that allows for powering P1 (not P2). Unfortunately, I2Cdevice is not present for prime hub or technic hub, only for EV3 hub (and there the powered does work, but is not effective, as the P1 pin is connected through a 330Ohm resistor, and the voltage drops sharply when connecting a device that draws some current.)
Proposed solution
I propose to add a keyword argument power_pin to the UARTDevice init method where the argument can be 0 (no power), 1 (P1 powered) or 2 (P2 powered).
In a pybricks program that would look like:
resulting in P1 powered and
resulting in P1 nor P2 powered.